home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / Sample Editors⁄Viewers / Draw Editor / Source / Selection.h < prev    next >
Encoding:
Text File  |  1995-12-11  |  5.2 KB  |  204 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Selection.h
  3.  
  4.     Contains:    Palette Classes Definition
  5.  
  6.     Written by:    Dave Stafford
  7.     
  8.     Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  9. */
  10.  
  11. // -- DrawEditor Includes --
  12.  
  13. #ifndef _SELECTION_
  14. #define _SELECTION_
  15.  
  16. #ifndef _DRAWCONTENT_
  17. #include "DrawContent.h"
  18. #endif
  19.  
  20. //=============================================================================
  21. // CSelection
  22. //=============================================================================
  23. class CSelection
  24. {
  25. public:
  26.     
  27.     // -- Init --
  28.     CSelection(DrawEditor* editor, ODBoolean allowPublish, ODBoolean allowSubscribe);
  29.     virtual ~CSelection();
  30.         
  31. public:
  32.     
  33.     // -- Accessors --
  34.     ODShape* GetUpdateShape();
  35.     
  36.     // -- Collection --
  37.     virtual ODBoolean    ContainsFrozen() const;
  38.     virtual ODBoolean    IsCompletelyUnfrozen() const; // HasNotFrozen    
  39.             void        SetFrozen(Environment* ev, ODBoolean state);
  40.     
  41.     virtual ODBoolean    IsEmpty() const;    
  42.     
  43.             void        Add(Environment* ev, CShape* shape);    
  44.             void        Remove(Environment* ev, CShape* shape);    
  45.     
  46.     // -- Drawing --
  47.     void                InvalidateSelection(Environment* ev, ODFrame* frame);
  48.     void                DrawSelectionHandles(Environment* ev, ODFacet* facet, ODBoolean turnOn);
  49.     void                DrawShapeHandles(Environment* ev, CShape* shape, ODBoolean turnOn);
  50.     void                DrawHandlesForAllFacets(Environment* ev, ODFrame* frame, ODBoolean turnOn);
  51.     
  52.     // -- Activation --
  53.     void                Activate(Environment* ev, ODBoolean activating, ODFrame* frame);
  54.     
  55.     // -- Selection --
  56.     ODBoolean            ClearSelection(Environment* ev, ODFrame* frame);
  57.     void                CloseSelection(Environment* ev);
  58.     void                SelectAll(Environment* ev, ODFrame* frame);
  59.     
  60.     void                AddToSelection(Environment* ev, CShape* theShape, ODBoolean drawHandles);    
  61.     void                RemoveFromSelection(Environment* ev, CShape* theShape, ODBoolean drawHandles);    
  62.     
  63.     ODBoolean            TrackRectangle(Environment* ev, ODEventData* event, Rect* selection);
  64.     void                SelectWithRectangle(Environment* ev, ODFacet* facet, ODEventData* event);
  65.     void                SelectWithShape(Environment* ev, 
  66.                                         ODFacet* facet, 
  67.                                         ODEventData* event, 
  68.                                         CShape* shape);
  69.     
  70.     void                ChangeSelectionColor(Environment* ev, const CRGBColor& color);
  71.  
  72.     // -- Dragging --
  73.     void                Dragging(Environment* ev, ODBoolean dragging );
  74.     void                GetSelectionRectangle(ODRect* rectangle);
  75.     ODShape*            CreateDragShape(Environment* ev, ODFacet* facet, ODFrame* frame);
  76.     
  77.     void                CalcUpdateShape(Environment* ev);    // Was CalcCache
  78.     void                OffsetSelection(Environment* ev,
  79.                                         ODFrame* containingFrame,
  80.                                         ODCoordinate hOffset, 
  81.                                         ODCoordinate vOffset);
  82.     
  83.     // -- Events --
  84.     CShape*                WhichHandle(Environment* ev, 
  85.                                     ODFacet* facet, 
  86.                                     const Point& mouse, 
  87.                                     short* whichHandle) const;
  88.  
  89.     // -- Resize --
  90.     void                TrackResize(Environment* ev,
  91.                                     ODFacet* facet,
  92.                                     ODEventData* event,
  93.                                     ODSShort whichHandle, 
  94.                                     CShape* shape, 
  95.                                     Point* result);
  96.                                     
  97.     void                 ResizeSelection(Environment* ev,
  98.                                     ODFrame* containingFrame,
  99.                                     Rect baseRect, 
  100.                                     Rect resizeRect);
  101.                                     
  102.                                 
  103.     void                Resize(Environment* ev, 
  104.                                 CShape* anchor,
  105.                                 ODFacet* containingFacet, 
  106.                                 short whichHandle, 
  107.                                 ODEventData* event);    
  108.  
  109.     
  110.     // ----- Change Notify -----
  111.     void                 SelectedContentUpdated(Environment* ev, ODBoolean doClear = kODFalse);
  112.     ODBoolean            IsPromisedToClipboard();
  113.     
  114.     // -- Storage --
  115.     
  116.     void        ExternalizeSingleEmbeddedFrame(Environment* ev, 
  117.                                                 ODStorageUnit* storage, 
  118.                                                 CCloneInfo* info, 
  119.                                                 ODFrame* embeddedFrame);
  120.     
  121.     void        HandleInternalizeContent(Environment* ev, 
  122.                                             ODStorageUnit* storageUnit, 
  123.                                             CCloneInfo* info);
  124.     
  125.     void        HandleTranslateContent(Environment* ev, 
  126.                                             ODStorageUnit* storageUnit, 
  127.                                             CCloneInfo* info,
  128.                                             ODBoolean embedOrMerge);
  129.     
  130.     void        SetInLimbo(Environment* ev, ODBoolean isInLimbo );
  131.     
  132.     // Linking
  133.     
  134.     CPublishLink         *FindPublisher();
  135.     
  136.     virtual void        AddShapeToPart(Environment* ev, CShape* shape);
  137.     void AddPublishLink(CPublishLink* link);
  138.  
  139.     void RemovePublishLink(CPublishLink* link);
  140.  
  141.     void AddSubscribeLink(CSubscribeLink* link);
  142.  
  143.     void RemoveSubscribeLink(CSubscribeLink* link);
  144.     void IncrementPartialSubscribeCount(ODUShort increment);
  145.  
  146.     ODBoolean CanMoveSelectedContent(CSubscribeLink*& link);
  147.     
  148.     ODBoolean CanEditSelectedContent();
  149.     ODBoolean CanPublish();
  150.     CEmbeddingShape* IsOneEmbeddedShape(Environment* ev);
  151.     COrderedList* GetShapeList();
  152.  
  153.     CDrawContent* GetSelectionContent();
  154.  
  155.     COrderedList* GetPublishLinks();
  156.  
  157.     COrderedList* GetSubscribeLinks();
  158.  
  159.     ODULong Count();
  160.  
  161.     DrawEditor* GetDrawEditor();
  162.     ODBoolean CanMoveSelectedContent();
  163.  
  164.     ODBoolean CanEditSelectedContent(CSubscribeLink*& link);
  165.  
  166.     ODBoolean IsOneLink();
  167.  
  168.  
  169.  
  170.  
  171.  
  172.     
  173.     
  174. //----------------------------------------------------------------------------------------
  175. // Data Members
  176. //
  177. private:
  178.     DrawEditor*            fDrawEditor;
  179.     ODUShort            fEmbeddingShapeCount;
  180.     ODUShort            fFrozenCount;
  181.     
  182.     Rect                fSelectionRectangle;
  183.     ODShape*            fUpdateShape;
  184.  
  185.     ODBoolean            fAllowPublish;
  186.     ODBoolean            fAllowSubscribe;
  187.     
  188.     ODUShort            fPartialSubscribeCount;
  189.     
  190.     CSelectionContent*     fSelectionContent;
  191.     
  192.     // convenience references
  193.     COrderedList*        fShapeList;    
  194.     COrderedList*        fPublishLinks;
  195.     COrderedList*        fSubscribeLinks;
  196.     
  197.     
  198. };
  199.  
  200.  
  201.  
  202.  
  203.  
  204. #endif